﻿using IService;
using Microsoft.AspNetCore.Mvc;
using Microsoft.IdentityModel.Logging;
using Model;

namespace WMS.Controllers
{
    public class LoginController : Controller
    {
        public IUserRoleService _iurs { get; set; }
        public IActionResult Index()
        {
            return View();
        }
        /// <summary>
        /// 登陆功能
        /// </summary>
        /// <param name="lu"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<IActionResult> Login([FromBody] LoginUser lu)
        {
            UserRole result = await _iurs.LoginAsync(lu.UserName, lu.Password);
            if (result.Id != 0)
            {
                return Ok(new { code = 200, data = result, msg = "登陆成功" });
            }
            else
            {
                return Ok(new { code = 404, msg = "请检查命名与用户名是否有误" });
            }
        }
    }
}
